﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Com.Web.coffinegurunaru.AppLogic.Page;
using Com.Framework;
using Com.Library.DB.Board;

namespace Com.Web.coffinegurunaru.manager.board
{
	public partial class article1_write : ManagerPage
	{
		public int PageNo
		{
			get;
			set;
		}

		public byte BoardSN
		{
			get;
			set;
		}

		public int ArticleSN
		{
			get;
			set;
		}
		public string Title
		{
			get;
			set;
		}

		public string Content
		{
			get;
			set;
		}

		public int ReadCount
		{
			get;
			set;
		}

		protected void Page_Load(object sender, EventArgs e)
		{
			PageNo = Request.QueryString["PageNo"].Parse(1);
			BoardSN = Request.QueryString["BoardSN"].Parse((byte)1);
			ArticleSN = Request.QueryString["ArticleSN"].Parse(0);

			if (this.IsPostBack)
			{
				Title = Request.Form["Title"].Parse(string.Empty);
				Content = Request.Form["Content"].Parse(string.Empty);
				ReadCount = Request.Form["ReadCount"].Parse(0);

				if (ArticleSN == 0)
				{
					ArticleModel.Create(BoardSN, Title, Content, string.Empty, this.WebCookies.ManagerSN, this.WebCookies.ManagerID, string.Empty, ReadCount);
				}
				else
				{
					ArticleModel.Modify(ArticleSN, Title, Content, string.Empty, string.Empty, ReadCount);
				}
				Response.Redirect("article1.aspx?BoardSN=" + BoardSN.ToString() + "&PageNo=" + PageNo.ToString());
			}
			else
			{
				ArticleEntity ArticleInfo = ArticleModel.GetInfo(ArticleSN, false, string.Empty, false);
				Title = ArticleInfo.strTitle;
				Content = ArticleInfo.strContent;
				ReadCount = ArticleInfo.n4ReadCount;
			}
		}
	}
}
